// import Vue from "vue";
import 'assets/css/main.scss'
import App from './App.vue'
import router from './router'
import store from './store'
// elementUI初始化
Vue.use(ELEMENT, { zIndex: '3000' })

import * as home from '@/api/home' // API接口
Vue.prototype.$home = home

import filter from './filters'
// 全局过滤器
Object.keys(filter).forEach(item => {
  Vue.filter(item, filter[item])
})

/**
   * @name 初始化数据内容
   */
// const { onGlobalStateChange } = initGlobalState({
//   userInfo: store.getters.userInfo,
//   token: store.getters.token
// })

/**
   * @name 监听数据变动
   * @param {Function} 监听到数据发生改变后的回调函数
   * @des 将监听到的数据存入vuex
   */
// onGlobalStateChange((value, prev) => {
//   value.token && store.dispatch('app/setToken', value.token)
//   value.userInfo && store.dispatch('app/setUserInfo', value.userInfo)
// })

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)

}).$mount('#app')

import { registerMicroApps, start } from 'qiankun'

registerMicroApps([
  {
    name: 'login',
    entry: 'http://localhost:4401',
    container: '#childContainer',
    activeRule: '/login',
    props: { data: { store, router }}
  },
  {
    name: 'anchor',
    entry: 'http://localhost:4402',
    container: '#childContainer',
    activeRule: '/anchor',
    props: { data: { store, router }}
  }
])

start()
